Skip to content

fix(cli): say what a refused flag, fill target, or drag endpoint expects - #5008

Merged
thymikee merged 3 commits into
callstack:mainfrom
imranbarbhuiya:fix/cli-error-messages
Nov 23, 2026
Merged

thymikee merged 3 commits into
callstack:mainfrom
imranbarbhuiya:fix/cli-error-messages

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three CLI messages sent agents the wrong way:

  • A refused flag value didn't say what was allowed.
  • fill $REF "136849" with an empty REF suggested text="136849", and fill "" 136849 was read as the point (0, 136849).
  • gesture drag "170 1595" "540 160" reached the device and failed there as a selector term.

Each refusal now names the fix and carries a typed details.reason: flag_value_invalid (with the bounds), fill_target_missing, or drag_endpoint_is_coordinates (with the equivalent pan). Env and config refusals share the range wording. help gestures now says that drag takes refs or selectors.

Before / after

Pixel 9 AVD (Android 16); base a4f2dcad0, head 944f1c74d:

$ open com.android.chrome --wait 240000
base: Invalid wait: 240000
head: Invalid wait: 240000. Expected integer from 100 to 120000.
$ fill 136849
base: …use text="136849"…
head: fill needs <target> <text> but got one value, "136849"…
$ gesture drag "170 1595" "540 160" 1200 800 600      # with a session open
base: Invalid selector term "170", expected key=value. May have reached the device.
head: INVALID_ARGS before dispatch. Next: For a coordinate hold-then-drag, use gesture pan 170 1595 370 -1435 800 --hold-ms 1200.

Validation

  • Head 944f1c74d, check:affected --run --head, exactCommit: true. Every gate passes except unit, where upload-http-deadline and committed-source-tree fail the same way on clean main on this macOS host. command-docs, doc-links and doc-prose pass when run directly.
  • The new tests assert reasons and details, and fail with their fixes reverted.

Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

A refused numeric or enum flag value printed only "Invalid wait: 240000",
so agents guessed what the flag meant. The parser now names the accepted
range or values ("Expected integer from 100 to 120000.") and returns
details.reason flag_value_invalid with the flag and its bounds. Env and
config refusals use the same describer, so --fps 500 and AGENT_DEVICE_FPS=500
read alike.
fill $REF "136849" with an unset REF reached the target decoder as one
value and was told to use text="136849", which sends the text to the
target slot. fill "$REF" "136849" decoded the blank target as x=0 and
reported missing text. Both now refuse with details.reason
fill_target_missing and say fill needs <target> <text>. One value that
holds a selector key, such as label=Sign in, keeps its quoting hint.
gesture drag "170 1595" "540 160" reached selector resolution on the
device and failed with Invalid selector term "170". The drag payload
reader now refuses a number, "x y" or "x,y" endpoint before dispatch
and before its timing checks, with details.reason
drag_endpoint_is_coordinates. When both endpoints are points and the
timing is valid, details.pan and the hint name the gesture pan --hold-ms
command that makes the same move.
@thymikee

Copy link
Copy Markdown
Member

Thanks for the clear error messages. The change at 944f1c7 is ready.

Not blocking, and each can be taken or left: describeAcceptedValues says "integer" for every int flag, but open --timeout 1.5 is accepted and floored while --timeout 0.5 is refused; readCoordinateEndpoint treats "," or "170," as coordinates because an empty segment becomes 0; decodeFillTarget swallows the decode error, so a caller that sends fill positionals straight to the daemon gets the generic message without fill_target_missing; and the fill_target_missing row in error-reasons.md sits in the middle of the fill table instead of with the other fill_* rows.

Smoke Tests failed in "Install Linux desktop dependencies" because apt-get update timed out on 3 attempts, before any repository test ran. That points to the runner, not this diff. The two Body rules runs were cancelled, not failed, and the PR body satisfies the check. All other 15 checks pass, including the docs gates. No conflicts.

Before merge, rerun Smoke Tests and the cancelled Body rules checks. No code change is needed. Not verified here: the unit tests and the Pixel 9 before/after run at base or head, and any other place that formats Invalid <flag>: text outside args.ts. None was found by search.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee
thymikee merged commit bf03fd7 into callstack:main Nov 23, 2026
15 of 18 checks passed
@imranbarbhuiya
imranbarbhuiya deleted the fix/cli-error-messages branch November 23, 2026 12:40
thymikee pushed a commit that referenced this pull request Nov 23, 2026
* fix(cli): say that an integer flag rounds a fractional value down

The refusal for an int flag said "Expected integer from 100 to 120000",
but the parser takes any number in range and floors it: open --timeout 1.5
runs with 1 while --timeout 0.5 is refused. The message now says
"Expected number >= 1 (rounded down to an integer)". Which values are
accepted does not change. Env and config values still say integer, since
those sources refuse a fraction.

* fix(gestures): read a drag endpoint with an empty segment as no coordinate

readCoordinateEndpoint split "," into two empty segments and "170," into
"170" and one, and Number("") is 0, so gesture drag refused both as the
coordinates (0, 0) and (170, 0). An empty segment now makes the endpoint
no coordinate, so it reaches the selector checks like any other malformed
target.

* fix(daemon): keep a typed fill target refusal on the daemon route

parseFillTarget caught every decode error and answered with the generic
"fill requires x y text, @ref text, or selector text", so a client that
sent fill positionals straight to the daemon lost fill_target_missing and
its guidance. A decode refusal with a typed reason now reaches the caller
with the message, reason and hint the CLI reports; other decode failures
keep the generic response.

The decoder quotes the positionals, and a --text-stdin or --record-as
fill's lone positional may be the text itself, so a sensitive fill keeps
the reason with a message that echoes none of them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants